﻿//
// <author>David Nohejl</author>
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WPFTrees.Parser;

namespace WPFTrees
{
    /// <summary>
    /// Interaction logic for GroupDlg.xaml
    /// </summary>
    public partial class GroupDlg : Window
    {
        public GroupDlg()
        {
            InitializeComponent();
        }


        public GroupDlg(GroupInfo info)
        {
            InitializeComponent();
            GroupName = info.Name;
            GroupColor = info.Color;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;            
        }

        /// <summary>
        /// Color of visual representation of the group.
        /// </summary>
        public Color GroupColor
        {
            get
            { 
                return (borderGroupColor.Background as SolidColorBrush).Color;
            }
            set 
            { 
                borderGroupColor.Background = new SolidColorBrush(value); 
            }
        }

        /// <summary>
        /// Name of the group.
        /// </summary>
        public string GroupName
        {
            get {return txtGroupName.Text;}
            set {txtGroupName.Text = value;}
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }

        private void btnChange_Click(object sender, RoutedEventArgs e)
        {
             WPFColorPickerLib.ColorDialog dlg 
                 = new WPFColorPickerLib.ColorDialog(this.GroupColor);
            if (dlg.ShowDialog() == true)
            {
                borderGroupColor.Background 
                    = new SolidColorBrush(dlg.SelectedColor);
            }        
        }
    }
}
